<?php
namespace App\Factory\Query;

use App\Utils\Other\Payment\Sandpay\Mini as SandpayMini;
use App\Utils\Other\Payment\Sumpay\Mini as SumpayMini;
use Hyperf\Context\Context;
use function Hyperf\Support\make;

Class Factory {

    /**
     * 衫德小程序支付
     * @param array $params
     * @return array
     * @throws \GuzzleHttp\Exception\GuzzleException
     */
    public function sandpayMini(array $params): array
    {
        /** @var SandpayMini $mini */
        $mini = make(SandpayMini::class);
        $mini->setConfig(Context::get('pay_config_array'));

        $params['mid'] = $mini->getConfig('mid');
        $params['outReqTime'] = date('YmdHis');

        return $mini->query($params);
    }

    /**
     * 统统付小程序支付
     * @param array $params
     * @return array
     */
    public function sumpayMini(array $params, array $config): array
    {
        /** @var SumpayMini $mini */
        $mini = make(SumpayMini::class);
        $mini->setConfig($config?:Context::get('pay_config_array'));

        return $mini->query($params);
    }
}